import pandas as pd
pd.set_option('display.unicode.east_asian_width', True)
df = pd.read_excel('student_info.xlsx', index_col=0, )
print('原始数据: \n', df)
df['体质指数'] = df['体重（kg）'] / df['身高（m）'] **2
df['健康状况'] = pd.cut(df['体质指数'], bins=[0, 18.5, 24, 28, 50],
right=False, include_lowest=True, labels=['消瘦','正常','超重','肥胖'])
print('计算机并离散化体质指数后的数据: \n', df)
print('对性别进行编码, 并设置附加前缀及其连接符为空的数据: \n',pd.get_dummies(df, prefix='',prefix_sep='',columns=['性别']))